import time

from selenium.webdriver.common.by import By

from base.BasePage import BasePage
from common.DriverTools import DriverTools
from page.web.WebIndexPage import WebIndexPage


class WebLoginPage(BasePage):
    def __init__(self,driver):
        self.driver = driver


    # 用户登录
    def web_login(self,username,passeord,vertify):
        # 1.输入用户名
        self.input_text(self.find_ele((By.ID,"username")),username)
        # 2.输入密码
        self.input_text(self.find_ele((By.ID, "password")), passeord)
        # 3.输入验证码
        self.input_text(self.find_ele((By.ID, "verify_code")), vertify)
        # 4.点击登录
        self.find_ele((By.NAME, "sbtbutton")).click()


if __name__ == '__main__':
    driver = DriverTools.get_driver()
    driver.get("http://hmshop-test.itheima.net/index.php/Home/Index/index.html")
    web_index = WebIndexPage(driver)
    web_index.go_to_login()
    web_login = WebLoginPage(driver)
    web_login.web_login(13245678990,123456,8888)
    time.sleep(2)
    DriverTools.quit_driver()
